home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1997 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.tu-chemnitz.de!news
  2. From: hfst@hrz.tu-chemnitz.de (Hans Steffani)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to link a FORTRAN subroutine into c program?
  5. Date: 18 Jan 96 07:14:41 GMT
  6. Organization: University of Technology Chemnitz, FRG
  7. Message-ID: <4dksak$k71@pyrrhus-f.hrz.tu-chemnitz.de>
  8. References: <4dj7bf$mud@usenet.ucs.indiana.edu>
  9. NNTP-Posting-Host: mmu.hrz.tu-chemnitz.de
  10.  
  11. ymao@copper.ucs.indiana.edu (Y.Mao) writes:
  12.  
  13.  
  14. >I am writing programs on DEC Alpha/OSF1. Sometimes I need to link a C 
  15. >function into a FORTRAN program, somehow I figured it out. However, I 
  16. >don't know how to link a FORTRAN subroutine as a C function.( I mean, 
  17. >call a FORTRAN subroutine in a C program).
  18.  
  19. This question is computer and compiler depending. Have a look
  20. at the section "mixed languages programming" in your documentations.
  21.  
  22. However there a some rules which are often valid.
  23.  
  24. You have to find out, which FORTRAN types are equivalent to
  25. which C types.
  26.  
  27. C calls by value, FORTRAN by reference therefore pass the adresses
  28. of your arguments instead of your arguments.
  29.  
  30. C may sort the arguments on the stack in a different way FORTRAN does.
  31. (C pushs the first argument as the last one FORTRAN as the first one)
  32.  
  33. Arrays in FORTRAN are lined up by the first index as in C by the last
  34. index.
  35.  
  36. Hans Friedrich Steffani
  37. --
  38. Hans Friedrich Steffani
  39. Institut fuer Elektrische Maschinen und Antriebe
  40. TU Chemnitz-Zwickau
  41. e-mail: hans.steffani@e-technik.tu-chemnitz.de
  42.